import 'package:boss/color_constant.dart';
import 'package:boss/textStyle/text_style.dart';
import 'package:hi_common/hi_common.dart';
import 'package:flutter/material.dart';

class TabBtn extends StatelessWidget {
  final String title;
  final VoidCallback onTap;
  final bool isSelected;
  final EdgeInsets margin;

  const TabBtn({
    Key key,
    @required this.title,
    this.onTap,
    this.isSelected = false,
    this.margin,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: onTap,
      behavior: HitTestBehavior.translucent,
      child: Container(
        margin: margin ??
            EdgeInsets.symmetric(
              horizontal: 30.w,
            ),
        child: Stack(
          children: <Widget>[
            Positioned(
              bottom: 0,
              left: 0,
              right: 0,
              child: Container(
                height: 8.w,
                decoration: BoxDecoration(
                  color: isSelected ? ColorConstant.ff5770f6 : Colors.transparent,
                  borderRadius: BorderRadius.circular(
                    8.w,
                  ),
                ),
              ),
            ),
            Text(
              title,
              style: isSelected
                  ? TextStyleConstant().normal_1_32
                  : TextStyleConstant().normal_4_28,
            ),
          ],
        ),
      ),
    );
  }
}
